package com.aiyige.utils;

import android.app.Activity;
import android.content.Intent;

import com.aiyige.MyApp;
import com.aiyige.configs.MyConfig;
import com.aiyige.page.detail.dialog.DialogAppComment;


/**
 * Created by xiachao on 2018/2/24.
 */

public class AppCommentUtils {

    private boolean needShowAppComment = true;

    private boolean isShowing = false;
    public static AppCommentUtils getInstance() {
        if (instance == null) {
            instance = new AppCommentUtils();
        }
        return instance;
    }

    private static AppCommentUtils instance;


    public boolean isNeedShowAppComment() {
        return needShowAppComment;
    }

    /**
     * App 本次启动时不再弹出显示
     * @param needShowAppComment
     */
    public void setNeedShowAppComment(boolean needShowAppComment) {
        this.needShowAppComment = needShowAppComment;
    }

    /**
     * 卸载之前永不再弹出
     */
    public void setShowAppCommentDisable() {
        needShowAppComment = false;
        MyApp.getInstance().getPrefs().putBoolean(MyConfig.IS_SHOW_APP_COMMENT, false);
    }

    public void showAppCommentDialog(Activity activity) {
        if (!isShowing &&needShowAppComment && activity != null && !activity.isFinishing()) {
            isShowing = true;
            Intent intent = new Intent(activity, DialogAppComment.class);
            activity.startActivity(intent);
        }
    }

}
